import Vue from 'vue'
import Vuex from 'vuex'
import SideBarItems from '../common/sidBarItem';
Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    status: {
      loggedIn: false,//是否登录
      userId: -1,//ID
      username: "",//姓名
      userType: 0,//用户的权限
      token:""//token
    },
    queueUseEle:{
      lineEle:[]//有序用电数据
    },
  sideBarItems:SideBarItems //静态页面先设置管理员side
  },
  getters: {
    lineEleData:state => state.queueUseEle.lineEle
  },
  mutations: {
    addLineEle(state,res){
      let lineEleItems = state.queueUseEle.lineEle;
      let flag = false
      for(let i = 0;i < lineEleItems.length;i++)
      {
        if(lineEleItems[i].id == res.id){
          lineEleItems[i].inputLimit = res.inputLimit;
          lineEleItems[i].perLimit = res.perLimit;
          lineEleItems[i].check = true
          flag = true;
          continue
        }
      }
      if(flag == false){
        res.check = true
        state.queueUseEle.lineEle.push(res);
      }
    }
  },
  actions: {
  },
  modules: {
  }
})
